﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/Content/BootstrapSouce/css/bootstrap.css" rel="stylesheet" />
    <script src="~/Content/BootstrapSouce/js/jquery.min.js"></script>
    <script src="~/Content/BootstrapSouce/js/bootstrap.min.js"></script>
    <script src="~/Content/EasyUI/jquery.min.js"></script>
    

</head>
<body>



    <div>
        <div class="row" style="height:50px">
            <div class="col-md-12" style="margin-top:10px;height:30px;background-color:#0094ff">

            </div>
        </div>

        <div class="row">
            <div class="col-md-12">
                <table class="table table-hover text-c">
                    <tr>
                        <th><input id="Checkbox1" type="checkbox" /></th>
                        <th>项目号</th>
                        <th>所属部门</th>
                        <th>勘察人</th>
                        <th>勘察开始时间</th>
                        <th>勘察结束时间</th>
                        <th>登记日期</th>
                        <th>建议评估单价（元/m2）</th>
                        <th>项目状态</th>
                        <th>操作</th>
                    </tr>
                    @foreach (var i in Model)
                    {

                       
                        <tr>
                            <td><input id="Checkbox1" type="checkbox" value="@i.projectNumber" /></td>
                            <td><a href="#" onclick="asses(@i.projectNumber)" data-target="#modal_add_userUpt" data-toggle="modal">@i.projectNumber</a></td>
                            <td>@i.department_Name</td>
                            <td>@i.users_Name</td>
                            <td>@i.survey_StartTime</td>
                            <td>@i.survey_EndTime</td>
                            <td>@i.basic_CreateTime</td>
                            <td>@i.basic_UnitPrice</td>
                            @switch ((int)i.basic_State)
                            {
                                case 0:
                                    <td>
                                        待勘察
                                    </td>
                                    break;
                                case 1:
                                <td>
                                    正在勘察
                                </td>
                                    break;
                                case 2:
                                <td>
                                    结束勘察
                                </td>
                                    break;
                                case 3:
                                <td>
                                    评估完成
                                </td>
                                    break;
                                case 4:
                                <td>
                                    初审未通过
                                </td>
                                    break;
                                case 5:
                                <td>
                                    初审通过
                                </td>
                                    break;
                                case 6:
                                <td>
                                    终审未通过
                                </td>
                                    break;
                                case 7:
                                <td>
                                    终审通过
                                </td>
                                    break;

                            }
                           

                            <td>
                                @if (i.basic_State == 2||i.basic_State==4||i.basic_State==6)
                                {
                                    <input id="Button1" type="button" value="进行评估" class="btn btn-primary" onclick="assess('@i.projectNumber')" data-toggle="modal" data-target="#modal_add_userUpts" />
                                    
                                }
                                <a href="/single/index?id=@(i.projectNumber)&idd=@i.basic_State" ;>查看勘察详情</a>
                            </td>
                        </tr>
                    }
                </table>
            </div>
        </div>
        <div class="row"></div>
    </div>


    <div class="modal fade" id="modal_add_userUpts" tabindex="-1" role="dialog" aria-labelledby="label_course">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="label_course"><strong>填写估价信息</strong></h4>
                </div>
                <div class="modal-body">
                    <table class="table table-striped">
                        <tr>
                            <td>估价目的</td>
                            <td><input type="text" id="basic_Evaluation" evve=""/></td>
                        </tr>
                        <tr>
                            <td>勘察起始时间</td>
                            <td><input type="text" id="survey_StartTime" /></td>
                        </tr>

                        <tr>
                            <td>勘察结束时间</td>
                            <td><input type="text" id="survey_EndTime" /></td>
                        </tr>
                        <tr>
                            <td>价值是点</td>
                            <td><input type="text" id="basic_ValueTime" /></td>
                        </tr>
                        <tr>
                            <td>建筑面积</td>
                            <td><input type="text" id="basic_Acreage" /></td>
                        </tr>
                        <tr>
                            <td>评估总值</td>
                            <td><input type="text" id="basic_Total" /></td>
                        </tr>
                        <tr>
                            <td>Excel估价计算清单</td>
                            <td><input id="File1" type="file" class="filebox" /></td>
                        </tr>
                        <tr>
                            <td>其他附件</td>
                            <td><input id="File1" type="file" class="filebox" /></td>
                        </tr>

                    </table>
                    <input type="button" value="提交" onclick="UptFull()" />
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="modal_add_userUpt" tabindex="-1" role="dialog" aria-labelledby="label_course">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="label_course"><strong>修改部门信息</strong></h4>
                </div>
                <div class="modal-body">
                    <table class="table table-striped">
                        <tr>
                            <td>估价目的</td>
                            <td><input type="text" id="basic_Evaluatio" /></td>
                        </tr>
                        <tr>
                            <td>勘察起始时间</td>
                            <td><input type="text" id="survey_StartTim" disabled /></td>
                        </tr>

                        <tr>
                            <td>勘察结束时间</td>
                            <td><input type="text" id="survey_EndTim" /></td>
                        </tr>
                        <tr>
                            <td>价值是点</td>
                            <td><input type="text" id="basic_ValueTim" /></td>
                        </tr>
                        <tr>
                            <td>建筑面积</td>
                            <td><input type="text" id="basic_Acreag" /></td>
                        </tr>
                        <tr>
                            <td>评估总值</td>
                            <td><input type="text" id="basic_Tota" /></td>
                        </tr>
                        <tr>
                            <td>Excel估价计算清单</td>
                            <td><input id="Button1" type="button" value="查看文件" /></td>
                        </tr>
                        <tr>
                            <td>其他附件</td>
                            <td><input id="Button1" type="button" value="查看文件" /></td>
                        </tr>

                    </table>
                    
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script>
    //修改提交
    function UptFull() {
        var survey_StartTime= $("#survey_StartTime").val();
        var  survey_EndTime= $("#survey_EndTime").val();
        var basic_ValueTime= $("#basic_ValueTime").val();
        var basic_Acreage= $("#basic_Acreage").val();
        var basic_Total = $("#basic_Total").val();
        var basic_Evaluation = $("#basic_Evaluation").val();
        var pro = $("#basic_Evaluation").attr("evve");
        $.ajax({
            url: "http://localhost:63805/api/Assess",
            data: { survey_StartTime: survey_StartTime, survey_EndTime: survey_EndTime, basic_ValueTime: basic_ValueTime, basic_Acreage: basic_Acreage, basic_Total: basic_Total, basic_Evaluation: basic_Evaluation, projectNumber:pro},
            type: "put",
            dataType: "json",
            success: function (obj) {
                if(obj>0)
                {
                    alert("添加成功");
                    location.reload();
                }
                else
                {
                    alert('添加事变');
                }
            }
        })
            
        
    }
    //反填
    function asses(id) {
        $.ajax({
            url: "http://localhost:63805/api/Assess/" + id,
            type: "get",
            success: function (obj) {
                $("#basic_Evaluatio").val(obj.basic_Evaluation);
                $("#survey_StartTim").val(obj.survey_StartTime);
                $("#survey_EndTim").val(obj.survey_EndTime);
                $("#basic_ValueTim").val(obj.basic_ValueTime);
                $("#basic_Acreag").val(obj.basic_Acreage);
                $("#basic_Tota").val(obj.basic_Total);
            }
        })
    }
    //评估的模态框弹出
    function assess(id) {
        $("#basic_Evaluation").attr("evve", id);
        $.ajax({
            url: "http://localhost:63805/api/Assess/" + id,
            type: "get",
            success: function (obj) {
                $("#survey_StartTime").val(obj.survey_StartTime);
                $("#survey_EndTime").val(obj.survey_EndTime);
            }
        })
        
    }
</script>